<template>
	<div class="train-batch">
		<div class="title-name title-border clear">
			<div class="title-name-l fl">
				<span>批卷阅卷</span>
			</div>
		</div>

		<div class="train-batch-content">
			<ul>
				<li class="train-batch-list" v-for="item of reviewList">
					<div class="train-batch-list-title clear">

						<router-link :to="{path: '/train/review', query: {trainid: item.train_id,train_little_id: item.train_little_id,test_id: item.res_id,name: item.test_name}}">{{item.test_name}}</router-link>

						<div class="train-list-operation fr">
							<el-popover
							  placement="bottom"
							  width="160"
							  popper-class="ioperation_hover"
							  trigger="hover">
							 	<ul class="r_ioperation">
									<li>
										<router-link :to="{path: '/train/review', query: {trainid: item.train_id,train_little_id: item.train_little_id,test_id: item.res_id}}">批阅</router-link>
									</li>
								</ul>
								<i slot="reference" class="el-icon-arrow-down"></i>
							</el-popover>
						</div>
					</div>

					<div class="train-batch-list-info">
						<span>时间： 
							<i>{{item.start_time.substring(0,16)}}</i>
							<em>-</em>
							<i>{{item.end_time.substring(0,16)}}</i>
						</span>
						<span>已完成人数: {{item.usercount}}人</span>
						<span>培训名称: {{item.train_name}}</span>
					</div>
				</li>
			</ul>
		</div>

		<el-pagination
		 	 background
		 	 v-if=" total_number > page_size"
		 	 class="pageing"
		     @size-change="sizeChange"
		     @current-change="currentChange"
		     :current-page="page_index"
		     :page-size="page_size"
		     layout="total, prev, pager, next, jumper"
		     :total="total_number">
		</el-pagination>

		<div class="dependent" v-if="placeholder">
			<i class="ipng image_state01"></i>
			<p>还没发现任何相关的内容哦~</p>
		</div>

	</div>
</template>

<script>
	
	export default{
		data() {
			return {
				page_index: 1,
				page_size: this.$g.page_size,
				total_number: 0,
				placeholder: false,
				reviewList: [],
			}
		},
		created(){
			this.get_reviewList()
		},
		methods:{
			get_reviewList(){
				let success = ( res=>{
					let data = res.data;
					this.reviewList = data.data;
					this.total_number = parseInt(data.data_sum);
					
					this.loading = false;
					this.reviewList.length === 0
					? this.placeholder = true
					: this.placeholder = false
				});

				this.$ajax({
					url: 'api/train/find_train_test_by_userid',
					method: 'get',
					params: {
						user_id: this.$g.user_id,
						page_index: this.page_index,
						page_size: this.page_size,
					},
					func: {success: success}
				})
			},
			sizeChange(val) {
				this.page_size = val
				this.get_reviewList()
			},
			currentChange(val) {
				this.page_index = val
				this.get_reviewList()
			}
		}
	}
</script>